﻿using System;
using System.Linq;
using System.Threading;
using Creventive.Wpf.ShellFactory.Logging;

namespace Creventive.Wpf.ShellFactory.Modules
{
    /// <summary>
    ///   Provides a default exception handling service.
    /// </summary>
    public class ExceptionHandlingService : IExceptionHandlingService
    {
        /// <summary>
        ///   Reports an exception.
        /// </summary>
        /// <param name = "thread">The thread the exception occurred in.</param>
        /// <param name = "exception">The exception.</param>
        /// <param name = "descriptionFormat">The description format.</param>
        /// <param name = "descriptionFormatArguments">The description format arguments.</param>
        public virtual void ReportException(Thread thread, Exception exception, string descriptionFormat, params object[] descriptionFormatArguments)
        {
            var logger = Logger.Default;
            if (descriptionFormat != null)
                logger.Error(exception, descriptionFormat, descriptionFormatArguments);
            else
                logger.Error(exception);
        }
    }
}